package cn.analysis.project.service.impl;

import cn.analysis.common.constant.LevelCons;
import cn.analysis.common.constant.TimeGroupCons;
import cn.analysis.framework.aspectj.lang.annotation.DataSource;
import cn.analysis.framework.aspectj.lang.enums.DataSourceType;
import cn.analysis.project.mapper.SysLevelMapper;
import cn.analysis.project.service.ISysLevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/** 分层健康度实现类 */
@Service
public class SysLevelServiceImpl implements ISysLevelService {

    @Autowired
    private SysLevelMapper levelMapper;

    /** 获取历史分层健康度 */
    @Override
    public Map<String, Object> selectListHisByGroup(String group, String code) {
        Map map = new HashMap();
        if (TimeGroupCons.DAY.equals(group)){
            map.put(LevelCons.A, levelMapper.selectListDayByName(LevelCons.A, code));
            map.put(LevelCons.B, levelMapper.selectListDayByName(LevelCons.B, code));
            map.put(LevelCons.C, levelMapper.selectListDayByName(LevelCons.C, code));
            map.put(LevelCons.D, levelMapper.selectListDayByName(LevelCons.D, code));
            map.put(LevelCons.E, levelMapper.selectListDayByName(LevelCons.E, code));
        }
        if (TimeGroupCons.WEEK.equals(group)){
            map.put(LevelCons.A, levelMapper.selectListWeekByName(LevelCons.A, code));
            map.put(LevelCons.B, levelMapper.selectListWeekByName(LevelCons.B, code));
            map.put(LevelCons.C, levelMapper.selectListWeekByName(LevelCons.C, code));
            map.put(LevelCons.D, levelMapper.selectListWeekByName(LevelCons.D, code));
            map.put(LevelCons.E, levelMapper.selectListWeekByName(LevelCons.E, code));
        }
        if (TimeGroupCons.MONTH.equals(group)){
            map.put(LevelCons.A, levelMapper.selectListMonthByName(LevelCons.A, code));
            map.put(LevelCons.B, levelMapper.selectListMonthByName(LevelCons.B, code));
            map.put(LevelCons.C, levelMapper.selectListMonthByName(LevelCons.C, code));
            map.put(LevelCons.D, levelMapper.selectListMonthByName(LevelCons.D, code));
            map.put(LevelCons.E, levelMapper.selectListMonthByName(LevelCons.E, code));
        }
        if (TimeGroupCons.QUARTER.equals(group)){
            map.put(LevelCons.A, levelMapper.selectListQuarterByName(LevelCons.A, code));
            map.put(LevelCons.B, levelMapper.selectListQuarterByName(LevelCons.B, code));
            map.put(LevelCons.C, levelMapper.selectListQuarterByName(LevelCons.C, code));
            map.put(LevelCons.D, levelMapper.selectListQuarterByName(LevelCons.D, code));
            map.put(LevelCons.E, levelMapper.selectListQuarterByName(LevelCons.E, code));
        }
        if (TimeGroupCons.YEAR.equals(group)){
            map.put(LevelCons.A, levelMapper.selectListYearByName(LevelCons.A, code));
            map.put(LevelCons.B, levelMapper.selectListYearByName(LevelCons.B, code));
            map.put(LevelCons.C, levelMapper.selectListYearByName(LevelCons.C, code));
            map.put(LevelCons.D, levelMapper.selectListYearByName(LevelCons.D, code));
            map.put(LevelCons.E, levelMapper.selectListYearByName(LevelCons.E, code));
        }
        return map;
    }

    /** 获取实时分层健康度数据 */
    @Override
    public List<Map<String, Object>> selectListNow(String code) {
        return levelMapper.selectListNow(code);
    }
}
